<?php
namespace Home\Controller;
use Think\Controller;
class PersonController extends CommonController {
    public function index(){
		if(isset($_SESSION['user_id']) && $_SESSION['user_id'] != ''
			&&isset($_SESSION['user_nickname']) && $_SESSION['user_nickname'] != '' ){
			$this->display();
		}else{
			$this->display("/Login/login");
		}
    }
    public function information(){
		$User = M ("User");
		$res = $User->where("user_id='{$_SESSION['user_id']}'")->find();
		if( $res == false){
			$this->error("参数错误");
		}else{
			$this->assign('res',$res);
			$this->display();
		}
	}
    public function info(){
		$User = M ("User");
			$rules = array(
				array('user_nickname','require','用户名必须！'), // 用户名必须
				array('user_name','require','用户名必须！'), // 用户名必须
				array('mobile_no','require','用户名必须！'), // 用户名必须
				array('email','require','用户名必须！'), // 用户名必须
			);
			$data = $User->validate($rules)->create();
			$ret = $User->where("user_id='{$_SESSION['user_id']}'")->save($data);
			if(!$ret){
				$this->error("信息修改失败");
			}else{
				$this->success("信息修改成功");
			}  
    }
    public function bjAddress(){
		$addr_id = I ("get.addr_id");
		$Address = M ("Address");
		$data = $Address->where("addr_id={$addr_id}")->find();
		if( $data == false){
			$this->error("参数错误");
		}else{
			$this->assign('data',$data);
			$this->display("bjAddress");
		}
	}
	public function order(){
		$this->display("order");
	}
	public function orderinfo(){
		$this->display("orderinfo");
	}
}
